package com.songshuai.webapi.permission.common.enumerations;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public enum TelephoneSystemType {
    ONE(1, "OB话机"),
    TWO(2, "阿里云CC"),
    THREE(3, "天润云CC"),
    FOUR(4, "汉天");


    private int code;
    private String msg;

    TelephoneSystemType(int code, String msg){
        this.code = code;
        this.msg = msg;
    }

    public static int getCode(String define){
        try {
            return TelephoneSystemType.valueOf(define).code;
        } catch (IllegalArgumentException e) {
            log.error("undefined error code: {}", define);
            return 0;
        }
    }

    public static String getMsg(String define){
        try {
            return TelephoneSystemType.valueOf(define).msg;
        } catch (IllegalArgumentException e) {
            log.error("undefined error code: {}", define);
            return "";
        }
    }

    public static String getMsg(Integer code){
        if(code==null||code<=0)
            return "";
        for(TelephoneSystemType err : TelephoneSystemType.values()){
            if(err.code==code){
                return err.msg;
            }
        }
        return "";
    }

    public int getCode(){
        return code;
    }

    public String getMsg(){
        return msg;
    }
}
